#include "stm32f10x.h"
#include <stdio.h>
#include "delay.h"
#include "gpio.h"
#include <stdbool.h>


bool LED_State = 0;
bool Beep_State = 0;
int main(void){
	static	uint32_t ts,last_ts;
	SystemInit();
	USER_GPIO_Init();
	dDelay_Init();
	SysTick_init();  
	BEEP_Init();
	Key_Init();
	while(1)
	{
	  if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == Bit_RESET )
		{
			while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == Bit_RESET );
			Beep_State = !Beep_State;
		}
		
		if(Beep_State)
		{
			GPIO_ResetBits(GPIOC,GPIO_Pin_9);	
		}
		else
		{
			GPIO_SetBits(GPIOC,GPIO_Pin_9);
		}
		if((GetTick() - last_ts) > 500)
		{
			last_ts = GetTick();
			
			LED_State = !LED_State;
		}
		
		if(LED_State)		
		    GPIO_ResetBits(GPIOC,GPIO_Pin_6);
		else 
		    GPIO_SetBits(GPIOC,GPIO_Pin_6);

	}
	}